﻿using Microsoft.Practices.Prism.ViewModel;
using System;

namespace CharacterCreation.Views.Contracts {
    /// <summary>
    /// Base view model
    /// </summary>
    public class BaseViewModel : NotificationObject {

        /// <summary>
        /// view model loaded event
        /// </summary>
        public event EventHandler<EventArgs> ViewLoaded;

        /// <summary>
        /// view model unloaded event
        /// </summary>
        public event EventHandler<EventArgs> ViewUnLoaded;

        
        /// <summary>
        /// Gets or sets the BaseView
        /// </summary>
        public BaseView BaseView {
            get { return _BaseView; }
            set {
                _BaseView = value;
                RaisePropertyChanged("BaseView");
            }
        }
        private BaseView _BaseView;
                
        
        /// <summary>
        /// Gets or sets the IsNewItem
        /// </summary>
        public bool IsNewItem {
            get { return _IsNewItem; }
            set {
                _IsNewItem = value;
                RaisePropertyChanged("IsNewItem");
            }
        }
        private bool _IsNewItem;
        
        /// <summary>
        /// Gets or sets the IsPopup
        /// </summary>
        public bool IsPopup {
            get { return _IsPopup; }
            set {
                _IsPopup = value;
                RaisePropertyChanged("IsPopup");
            }
        }
        private bool _IsPopup;

        /// <summary>
        /// Fires when the view is loaded
        /// </summary>
        public virtual void OnViewLoaded() {
            if (ViewLoaded != null) ViewLoaded(this, null);
        }

        /// <summary>
        /// Fires when the view is unloaded.
        /// </summary>
        public virtual void OnViewUnloaded() {
            if (ViewUnLoaded != null) ViewUnLoaded(this, null);
        }
    }
}
